//
//  LZComDoctorView.m
//  DoctorFAQs
//
//  Created by langZai on 2017/3/30.
//  Copyright © 2017年 zjq. All rights reserved.
//

#import "LZComDoctorView.h"

@interface LZComDoctorView () {
    // 头像
    UIImageView *_iconImageView;
    // 姓名
    UILabel *_nameLabel;
    // 科室
    UILabel *_officeLabel;
    // 主治医生
    UILabel *_doctorLabel;
    // 医院
    UILabel *_hospitalLabel;
    // 职业编号
    UILabel *_numLabel;
    
}

@end


@implementation LZComDoctorView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        // 创建UI
        [self createUI];
        // 添加
        [self addUI];
        // 约束
        [self makeConstraints];
        
    }
    return self;
}

- (void)createUI {
    self.backgroundColor = [UIColor whiteColor];
    //icon_hospital_green
    _iconImageView = [[UIImageView alloc] init];
    _iconImageView.image = [UIImage imageNamed:@"about-us"];
    _iconImageView.layer.cornerRadius = 30*ysIZE;
    _iconImageView.layer.masksToBounds = YES;
    
    _nameLabel = [[UILabel alloc] init];
    _nameLabel.text = @"张大彪";
    _nameLabel.font = NEWFONT(18);
    _nameLabel.textColor = KHColorFromRGB(0x333333);
    
    _officeLabel = [[UILabel alloc] init];
    _officeLabel.text = @"皮肤科";
    _officeLabel.textColor = KHColorFromRGB(0x999999);
    _officeLabel.font = NEWFONT(14);
    
    _doctorLabel = [[UILabel alloc] init];
    _doctorLabel.textColor = KHColorFromRGB(0x999999);
    _doctorLabel.font = NEWFONT(14);
    _doctorLabel.text = @"主治医师";
    
    _hospitalLabel = [[UILabel alloc] init];
    _hospitalLabel.textColor = KHColorFromRGB(0x666666);
    _hospitalLabel.text = @"成都妇女儿童医院";
    _hospitalLabel.font = NEWFONT(13);
    
    
    _numLabel = [[UILabel alloc] init];
    _numLabel.text = @"职业编号:la1232131231";
    _numLabel.font = NEWFONT(12);
    _numLabel.textColor = KHColorFromRGB(0x999999);
    
    
}

- (void)addUI {
    [self addSubview:_iconImageView];
    [self addSubview:_nameLabel];
    [self addSubview:_doctorLabel];
    [self addSubview:_officeLabel];
    [self addSubview:_hospitalLabel];
    [self addSubview:_numLabel];
}

- (void)makeConstraints {
    [_iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(self).offset(10*xsIZE);
        make.width.offset(60*xsIZE);
        make.height.offset(60*ysIZE);
    }];
    
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(10*xsIZE);
        make.left.equalTo(_iconImageView.mas_right).offset(10*xsIZE);
    }];
    
    [_officeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_nameLabel);
        make.left.equalTo(_nameLabel.mas_right).offset(10*xsIZE);
    }];
    
    [_doctorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_nameLabel);
        make.left.equalTo(_officeLabel.mas_right).offset(10*xsIZE);
    }];
    
    // 绿色➕
    UIImageView *addImageView = [[UIImageView alloc] init];
    addImageView.image = [UIImage imageNamed:@"icon_hospital_green"];
    [self addSubview:addImageView];
    [addImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_iconImageView);
        make.width.offset(10*xsIZE);
        make.height.offset(10*ysIZE);
        make.left.equalTo(_iconImageView.mas_right).offset(10*xsIZE);
    }];
    
    
    [_hospitalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_iconImageView);
        make.left.equalTo(_iconImageView.mas_right).offset(25*xsIZE);
    }];

    [_numLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_iconImageView.mas_right).offset(10*xsIZE);
        make.top.equalTo(_hospitalLabel.mas_bottom).offset(10*ysIZE);
    }];
}

-(void)setLz_doctorModel:(LZComDoctorModel *)lz_doctorModel {
    _lz_doctorModel = lz_doctorModel;
    // 头像
    [_iconImageView sd_setImageWithURL:[NSURL URLWithString:_lz_doctorModel.pic] placeholderImage:[UIImage imageNamed:@"about"]];
    _nameLabel.text = _lz_doctorModel.name;
    _officeLabel.text = _lz_doctorModel.office;
    _doctorLabel.text = _lz_doctorModel.job_title;
    _hospitalLabel.text = _lz_doctorModel.hospital;
    _numLabel.text = _lz_doctorModel.number;
    
}



@end
